<template>
	<view class="page-box">
		<view class="page-title">
			<view class="title-text">{{data.PROJNAME}}</view>
		</view>
		<view class="page-title-os">
			<view class="title-icon"  @click="getOldHistory">
				<image src="../../static/images/icon_menu_04.png" mode="" ></image>
				<view class="icon-right">引用历史</view>
			</view>
			<view class="title-icon" @click="goHistory">
				<image src="../../static/images/icon_menu_04.png" mode=""></image>
				<view class="icon-right">历史送报</view>
			</view>
		</view>
		<view class="page-tag">综合评审</view>
		<form @submit="handleSubmit">
		<view class="page-form">
			
			<view class="form-item">
				<view class="uni-title uni-common-pl">项目简介</view>
				<view class="uni-textarea">
					<textarea class="style-text"  auto-height placeholder="请填项目简介" name="PROJBASEINFO" v-model="data.PROJBASEINFO" disabled/>
				</view>
			</view>
			<view class="form-item">
				<view class="uni-title uni-common-pl">企业诉求</view>
				<view class="uni-textarea">
					<textarea class="style-text"  auto-height placeholder="请填企业诉求" name="REQUIREMENT" v-model="data.REQUIREMENT"/>
				</view>
			</view>
			<view class="form-item">
				<view class="uni-title uni-common-pl">对接情况</view>
				<view class="uni-textarea">
					<textarea class="style-text"  auto-height placeholder="请填对接情况" name="PROGRESS" v-model="data.PROGRESS"/>
				</view>
			</view>
			<view class="form-item">
				<view class="uni-title uni-common-pl">下一步推进及所需支持</view>
				<view class="uni-textarea">
					<textarea class="style-text"  auto-height placeholder="请填推进支持" name="NEXTWORK" v-model="data.NEXTWORK"/>
				</view>
			</view>
			<view class="form-item">
				<view class="uni-title uni-common-pl">其他</view>
				<view class="uni-textarea">
					<textarea class="style-text"  auto-height placeholder="请填备注内容" name="OTHER" v-model="data.OTHER"/>
				</view>
			</view>
			
		</view>
		<view class="fixed-action-bar">
			<view class="item">
				<button class="btn-box" form-type="submit">
					<image src="../../static/images/icon_save.png" mode="widthFix" class="icon"></image>
					<text class="text-edit">提交送报</text>
				</button>
			</view>
			<view class="item" @click="handleCancel">
				<view class="btn-box">
					<image src="../../static/images/icon_next.png" mode="widthFix" class="icon"></image>
					<text class="text-delete">返回取消</text>
				</view>
			</view>
		</view>
		</form>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				historyData:{},
				data:{
					
				},
				options:{}
			}
		},
		methods: {
			bindTextAreaBlur(e) {
				console.log(e.detail.value)
			},
			async handleSubmit(e){
				
				const formData = {...e.detail.value};
				formData.isadding = false;
				formData.DATAKEY = this.options.dataKey
				uni.showLoading({
					
				})
				const ret = await this.$req({
					url:'bus/reportmanage/save.do',
					data:formData
				})
				uni.hideLoading()
				if(ret.data.success){
					// this.$req({
					// 	url:'/bus/reportview/modify.do',
					// 	data:{dataKey:ret.data.attributes.dataKey }
					// })
					uni.showToast({
						title:'提交报送成功',
						icon:'none'
					})
					uni.switchTab({
						url:'../index/index'
					})
				} else {
					uni.showToast({
						title:ret.data.messages[0].content,
						icon:'none'
					})
				}
			},
			handleCancel(){
				uni.switchTab({
					url:'../index/index'
				})
			},
			async getData(params){
				uni.showLoading({
					
				})
				const ret = await this.$req({
					url:'bus/reportmanage/toUpdate.do',
					data:params
				})
				if(ret.data.success){
					this.data = ret.data.attributes.model
					this.historyData=ret.data.attributes.history
				} else {
					uni.showToast({
						title:ret.data.messages[0].content
					})
				}
				uni.hideLoading()
				console.log('ret',ret)
			},
			async getOldHistory(){
				if(this.historyData&&this.historyData.length){
					this.data = this.historyData[0]
				}else{
					uni.showToast({
						title:'项目未记录历史更新版本'
					})
				}
			},
			goHistory(){
				uni.navigateTo({
					url:`/pages/historyReport/historyReport?historyData=` + JSON.stringify(this.historyData),
				})
			},
		},

		onLoad(options){
			this.options = options;
			this.getData(options)
			console.log('options',options)
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #e9f0f2;
	}
	.page-box{
		margin: 20rpx 30rpx;
		padding: 38rpx 30rpx;
		width: 690rpx;
		background-color: #ffffff;
		border-radius: 20rpx;
		.page-title{
			display: flex;
			// justify-content: space-between;
			align-items: center;
			.title-text{
				font-family: Alibaba-PuHuiTi-B;
				font-weight: 700;
				font-size: 30rpx;
				color: #414a5d;
			}
			.title-icon{
				display: flex;
				align-items: center;
				
				image{
					width: 27rpx;
					height: 27rpx;
					margin-right: 10rpx;
				}
				.icon-right{
					font-size: 24rpx;
					line-height: 34rpx;
					color: #0099cc;
				}
			}
		}
		.page-title-os{
			display: flex;
			justify-content: flex-end;
			align-items: center;
			.title-icon{
				display: flex;
				align-items: center;
				margin-left: 30rpx;
				image{
					width: 27rpx;
					height: 27rpx;
					margin-right: 10rpx;
				}
				.icon-right{
					font-size: 24rpx;
					line-height: 34rpx;
					color: #0099cc;
				}
			}
		}
		.page-tag{
			width: 120rpx;
			height: 30rpx;
			margin-top: 14rpx;
			font-size: 24rpx;
			line-height: 30rpx;
			text-align: center;
			background-color: #00ac0c;
			border-radius: 4rpx;
			color: #FFFFFF;
		}
		.page-form{
			margin-top: 32rpx;
			// padding: 0 40rpx;
			.form-item{
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				margin-bottom: 30rpx;
				min-height: 108rpx;
				.uni-title{
					width: 130rpx;
					font-size: 26rpx;
					color: #414a5d;
				}
				.uni-textarea{
					width: 430rpx !important;
					font-size: 26rpx;
					line-height: 36rpx;
					border-bottom: 2rpx solid #dce4e6;
					color: #808080;
					/deep/.uni-textarea-wrapper{
						width: 430rpx !important;
					}
				}
				.style-text{
					width: 430rpx !important;
					font-size: 26rpx;
					line-height: 34rpx;
				}
			}
		}
		
	}
	
	.fixed-action-bar{
		width: 100%;
		display: flex;
		height: 70rpx;
		align-items: center;
		background: #fff;
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 999;
		.item{
			width: 50%;
			display: flex;
			justify-content: center;
			align-items: center;
			
		}
		.icon{
			width: 30rpx;
		}
		.btn-box{
			width: 140rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			height: 70rpx;
		}
		.text-edit{
			font-size: 24rpx;
			color: #0099cc;
			line-height: 70rpx;
		}
		.text-delete{
			font-size: 24rpx;
			color: #cc3357;
			line-height: 70rpx;
		}
	}
</style>
